package com.kongzue.baseokhttpv3.newslice;

import com.kongzue.baseokhttp.util.BaseOkHttp;
import com.kongzue.baseokhttp.util.BaseOkHttpConfig;
import com.kongzue.baseokhttpv3.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.TextField;
import ohos.agp.window.dialog.ToastDialog;
import org.apache.http.util.TextUtils;

public class TimeAbilitySlice extends AbilitySlice {
    private TextField asktime;
    private Button save;


    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_time);
        save = (Button) findComponentById(ResourceTable.Id_save);
        asktime = (TextField) findComponentById(ResourceTable.Id_ask_time);
        save.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                ToastDialog toastDialog = new ToastDialog(TimeAbilitySlice.this);
                if (TextUtils.isEmpty(asktime.getText())) {
                    toastDialog.setText("Do not empty").setDuration(1000).show();
                    return;
                }
                BaseOkHttpConfig.getInstance().setTimeOutDuration(Integer.valueOf(asktime.getText().toString()));

                toastDialog.setText("OK").setDuration(1000).show();
            }
        });
    }
}
